﻿using ACC.Business.Stn;
using ACC.Business.Utils;
using ACC.Data.ACCLog;
using ACC.Data.Comm;
using ACC.Data.Entities.Mes;
using ACC.Data.Line;
using ACC.Device;
using ACC.LineDevice.KukaPack;
using System;
using System.Collections.Generic;
using System.Linq;


namespace Script
{
    /// <summary>
    /// 电芯检测（测厚、电压、内阻） OP L1M01040,  STN L1M11041 , L1M21041
    /// </summary>
    public class L1M01040 : StnProcessPL02_DX
    {
        public L1M01040(StnRunningData data)
            : base(data)
        {
        }

        protected override ACCDevice CreateDevice()
        {
            ACCDevice dev = base.CreateDevice();
            if (kukaSiemensDev != null)
            {
                switch (_data.StnCfg.Name)
                {
                    case "L1M11041":
                        {
                            kukaSiemensDev.DB190_Offset = 1000;
                        }
                        break;
                    case "L1M21041":
                        {
                            kukaSiemensDev.DB190_Offset = 4000;
                        }
                        break;
                }

                kukaSiemensDev.DB190 = 800;
                kukaSiemensDev.DB192 = 80;
                kukaSiemensDev.DB192_PLC_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 258);
                kukaSiemensDev.DB193 = 800;
                kukaSiemensDev.DB193_PLC_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 34);
                kukaSiemensDev.DB193_ACC_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 68);
                kukaSiemensDev.DB194 = 800;
                kukaSiemensDev.DB194_PLC_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 34);
                kukaSiemensDev.DB194_PLC_Data_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 270);
                kukaSiemensDev.Material_COMM_Offset = 260; // 260, 4260? 上下料信号位偏移量
                kukaSiemensDev.ProcessDataStringDataLength = 10;
                kukaSiemensDev.ProcessDataRealLength = 60;
                kukaSiemensDev.BarcodeLength = 30;
                kukaSiemensDev.LoadBarcodeCount = 6;
                kukaSiemensDev.UnloadBarcodeCount = 6;
            }

            return dev;

        }

        protected override void CreateBusinessLogic()
        {
            base.CreateBusinessLogic();

            (_loadProcess as LoadProcess_DX).R = 4;
            (_unloadProcess as UnloadProcess_DX).R = 4;
        }
    }
}